package com.ecfront.dao.impl;

import java.util.Date;
import java.util.List;
import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.ecfront.dao.PayDAO;
import com.ecfront.pojo.Pay;


/**
 * @version 1.0
 * @author www.ecfrom.com
 */

public class PayDAOImpl extends HibernateDaoSupport implements PayDAO {

	protected void initDao() {}

	public void save(Pay transientInstance) {
		getHibernateTemplate().save(transientInstance);
	}

	public void delete(Pay persistentInstance) {
		getHibernateTemplate().delete(persistentInstance);
	}

	public Pay findById(java.lang.Integer id) {
		Pay instance = (Pay) getHibernateTemplate().get(
					"com.ecfront.pojo.Pay", id);
		return instance;
	}

	public List findByExample(Pay instance) {
		List results = getHibernateTemplate().findByExample(instance);
		return results;
	}


	public List findByProperty(String propertyName, Object value) {
		String queryString = "from Pay as model where model."
					+ propertyName + "= ?";
		return getHibernateTemplate().find(queryString, value);
	}

	public List findByPprice(Object pprice) {
		return findByProperty(PPRICE, pprice);
	}

	public List findByPuserName(Object puserName) {
		return findByProperty(PUSER_NAME, puserName);
	}

	public List findByPadd(Object padd) {
		return findByProperty(PADD, padd);
	}

	public List findByPzip(Object pzip) {
		return findByProperty(PZIP, pzip);
	}

	public List findByPphone(Object pphone) {
		return findByProperty(PPHONE, pphone);
	}


	public List findByPmobilePhone(Object pmobilePhone) {
		return findByProperty(PMOBILE_PHONE, pmobilePhone);
	}


	public List findByPpayBank(Object ppayBank) {
		return findByProperty(PPAY_BANK, ppayBank);
	}

	public List findByPpayNbr(Object ppayNbr) {
		return findByProperty(PPAY_NBR, ppayNbr);
	}

	public List findByPsendCompany(Object psendCompany) {
		return findByProperty(PSEND_COMPANY, psendCompany);
	}

	public List findByPsndNbr(Object psndNbr) {
		return findByProperty(PSND_NBR, psndNbr);
	}

	public List findAll() {
		String queryString = "from Pay";
		return getHibernateTemplate().find(queryString);
	}


	public Pay merge(Pay detachedInstance) {
		Pay result = (Pay) getHibernateTemplate().merge(detachedInstance);
		return result;
	}


	public void attachDirty(Pay instance) {
		getHibernateTemplate().saveOrUpdate(instance);
	}

	public void attachClean(Pay instance) {
		getHibernateTemplate().lock(instance, LockMode.NONE);
	}

	public List findByPstate(Object state) {
		return findByProperty(PSTATE, state);
	}
	
	public static PayDAO getFromApplicationContext(ApplicationContext ctx) {
		return (PayDAO) ctx.getBean("PayDAO");
	}
}